import { _decorator, assetManager, Component, director, Node, Prefab, SpriteFrame } from 'cc';
import { GameData } from '../MigaWorlds/Scripts/GameData';
import Banner from './Banner';
import { Constant } from './Framework/Const/Constant';
import PrefsManager from './Framework/Managers/PrefsManager';
import { UIManager, Panel } from './Framework/Managers/UIManager';
const { ccclass, property } = _decorator;

@ccclass('Policy')
export class Policy extends Component {

    AgreePolicy: boolean;

    start() {
        GameData.Instance
        if (!PrefsManager.GetBool(Constant.Key.AgreePolicy) && !Banner.IS_ANDROID && !Banner.IS_BYTEDANCE_MINI_GAME && !Banner.IS_WECHAT_MINI_GAME) {
            UIManager.ShowPanel(Panel.PrivacyPanel, [true, () => {
                this.AgreePolicy = true;
                this.SuccessCallback();
            }]);
        } else {
            this.AgreePolicy = true;
            this.SuccessCallback();
        }
    }

    update(deltaTime: number) {

    }

    SuccessCallback() {
        if (this.AgreePolicy) {
            console.log("所有资源加载完成，进入游戏场景");
            this.scheduleOnce(() => {
                director.loadScene("Start");
            }, 1);
        }
    }
}


